<%@ Page Language="VB"  MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ManualEntry.aspx.vb" Inherits="ManualEntry" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
      <asp:SqlDataSource ID="sqlDataSourcesByVendor" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
        SelectCommand="SELECT DataSourceVendor.DataSourceVendorId, Vendors.Name + ': ' + DataSources.DataSource AS Source FROM Vendors INNER JOIN DataSourceVendor ON Vendors.VendorId = DataSourceVendor.VendorId INNER JOIN DataSources ON DataSourceVendor.DataSourceId = DataSources.DataSourceId WHERE (DataSourceVendor.Manual = 1) ORDER BY Vendors.Name, DataSources.DataSource">
      </asp:SqlDataSource>
      <asp:SqlDataSource ID="sqlStats" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
        SelectCommand="SELECT * FROM (SELECT Colleges.ShortName, Colleges.CollegeId, Month(Month) AS monthnum, Quantity FROM CollegeDataSourceVendor INNER JOIN Stats ON CollegeDataSourceVendor.CollegeDataSourceVendorId = Stats.CollegeDataSourceVendorId INNER JOIN Colleges ON CollegeDataSourceVendor.CollegeId = Colleges.CollegeId WHERE (Stats.Month BETWEEN CONVERT(DATETIME, @BegDate, 102) AND CONVERT(DATETIME, @EndDate, 102)) AND (CollegeDataSourceVendor.DataSourceVendorId = @DataSourceVendorId) AND Stats.StatsTypeId = @StatsTypeId UNION SELECT ShortName, CollegeId, 0, 0 FROM Colleges) AS o PIVOT (sum(Quantity) FOR MonthNum IN ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])) AS p ORDER BY ShortName">
        <SelectParameters>
          <asp:Parameter DefaultValue="2008-1-1" Name="BegDate" Type="DateTime" />
          <asp:Parameter DefaultValue="2008-12-1" Name="EndDate" Type="DateTime" />
          <asp:ControlParameter ControlID="ddlVendors" Name="DataSourceVendorId" PropertyName="SelectedValue"
            Type="Int32"/>
          <asp:ControlParameter ControlID="ddlStatsType" DefaultValue="" Name="StatsTypeId"
            PropertyName="SelectedValue" />
        </SelectParameters>
      </asp:SqlDataSource>
      <asp:SqlDataSource ID="sqlStatsType" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>" SelectCommand="SELECT [StatsTypeId], [StatsType] FROM [StatsTypes]"></asp:SqlDataSource>
  <br />
      <asp:DropDownList ID="ddlVendors" runat="server" AutoPostBack="True" DataSourceID="sqlDataSourcesByVendor"
        DataTextField="Source" DataValueField="DataSourceVendorId">
      </asp:DropDownList>
      Year &nbsp;<asp:DropDownList
        ID="ddlYear" runat="server" AutoPostBack="True">
      </asp:DropDownList>
      <asp:DropDownList ID="ddlStatsType" runat="server" AutoPostBack="True" Width="118px" DataSourceID="sqlStatsType" DataTextField="StatsType" DataValueField="StatsTypeId">
      </asp:DropDownList>
  <asp:TextBox ID="txtYearSave" runat="server" EnableViewState="False" Width="55px" Visible="False"></asp:TextBox>
  <asp:TextBox ID="txtDSVIdSave" runat="server" EnableViewState="False" Width="50px" Visible="False"></asp:TextBox>
  <asp:TextBox ID="txtStatsTypeSave" runat="server" EnableViewState="False" Width="51px" Visible="False"></asp:TextBox><br />
      <br />
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sqlStats" GridLines="None">
        <Columns>
          <asp:BoundField DataField="ShortName" HeaderText="College" ReadOnly="True" SortExpression="ShortName"/>
          <asp:TemplateField HeaderText="Jan" SortExpression="1">
            <ItemTemplate>
              <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("1") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Feb" SortExpression="2" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("2") %>' Width="46px"  OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="TextBox2"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Mar" SortExpression="3" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("3") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator3" runat="server" ControlToValidate="TextBox3"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Apr" SortExpression="4" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("4") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator4" runat="server" ControlToValidate="TextBox4"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="May" SortExpression="5" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("5") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator5" runat="server" ControlToValidate="TextBox5"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Jun" SortExpression="6" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("6") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator6" runat="server" ControlToValidate="TextBox6"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Jul" SortExpression="7" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("7") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator7" runat="server" ControlToValidate="TextBox7"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Aug" SortExpression="8" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("8") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator8" runat="server" ControlToValidate="TextBox8"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="Sep" SortExpression="9" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("9") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator9" runat="server" ControlToValidate="TextBox9"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField  HeaderText="Oct" SortExpression="10" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("10") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator10" runat="server" ControlToValidate="TextBox10"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField  HeaderText="Nov" SortExpression="11" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("11") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator11" runat="server" ControlToValidate="TextBox11"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField  HeaderText="Dec" SortExpression="12" >
            <ItemTemplate>
              <asp:TextBox ID="TextBox12" runat="server" Text='<%# Bind("12") %>' Width="46px" OnTextChanged="TextBox_TextChanged"></asp:TextBox>
              <asp:RangeValidator ID="RangeValidator12" runat="server" ControlToValidate="TextBox12"
                Display="Dynamic" ErrorMessage="Numbers Only" MaximumValue="999999" MinimumValue="0"
                SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
          </asp:TemplateField>
          <asp:TemplateField Visible=False>
            <ItemTemplate>
              <asp:Label ID="CollegeId" runat="server" Text='<%# Bind("CollegeId") %>'></asp:Label>
            </ItemTemplate>
          </asp:TemplateField>
        </Columns>
        <AlternatingRowStyle BackColor="#E0E0E0" />
      </asp:GridView>

      <asp:Button ID="Button1" runat="server" Text="Update" EnableViewState="False" />
  <br />

</asp:Content>